package com.isunland.managesystem.ui;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BasePagerActivity;
import com.isunland.managesystem.entity.RequisitionSimpleOriginal;
import com.isunland.managesystem.utils.LogUtil;

/**
 * 对象功能:  新批量外出 pager
 * 开发公司: 北京信普达系统工程有限公司
 * 开发人员: HuXiaoDan
 * 创建时间: 2017/3/3 10:19
 */
public class CheckOutPagerActivity extends BasePagerActivity
    implements CheckOutMainFragment.CallBack {

  private RequisitionSimpleOriginal content;
  private String ifAllowSupplement;

  @Override protected void onCreate(Bundle arg0) {
    content = (RequisitionSimpleOriginal) getIntent().getSerializableExtra(
        CheckOutMainFragment.EXTRA_CONTENT);
    ifAllowSupplement = getIntent().getStringExtra(CheckOutMainFragment.EXTRA_IFALLOWSUPPLEMENT);
    super.onCreate(arg0);
  }

  @Override protected Fragment createFragmentOne() {
    return CheckOutMainFragment.newInstance(content, CheckOutMainFragment.OUT, ifAllowSupplement);
  }

  @Override protected Fragment createFragmentTwo() {
    if (content != null) {
      return CheckOutListFragment.newInstance(content.getId(), content.getDataStatus(),
          content.getIfLaterWrite());
    } else {
      return CheckOutListFragment.newInstance("-1", "new", "F");
    }
  }

  @Override protected int[] createTitle() {
    return new int[] { R.string.requisitionout, R.string.outList };
  }

  @Override public void onRefresh(String pid, String ifLaterWriter) {
    LogUtil.i("添加保存id===" + pid);
    setNavigateTo(1);//跳转到第二个tab页
    CheckOutListFragment.updataId(pid, ifLaterWriter);
  }
}
